<%@page contentType="text/html; charset=UTF-8" %>
<jsp:useBean id="user" class="entity_beans.User" scope="session"></jsp:useBean>
<jsp:useBean id="auxBean" class="model.AuxBean" scope="request"></jsp:useBean>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Air Transport - Add New Flight</title>
</head>
<body>
<%! boolean addFlag = false; %>
<%
	if (user.isAccessed() == false) {
		response.sendRedirect("../index.jsp");
		return;
	}

	if ( user.isLoggedIn() == false ) {
		response.sendRedirect("../index.jsp");
		return;
	}
	
	String flightID = request.getParameter("flightid");
	addFlag = Boolean.parseBoolean(request.getParameter("flag"));
%>



<h2><u>Air Transport Service - Add New Flight</u></h2>

<jsp:include page="header.jsp"></jsp:include>


<form name="forma" method="post" action="../AddNewFlightServlet">

<table BORDER="2" cellspacing="2">

<tr>
<td style="BACKGROUND-COLOR: #a8da8f;">Flight ID:</td>
<td align="center">
<input id="flightID" name="flightID" size="20"  TYPE="TEXT" style="float:left"></td>
</tr>
<tr>
<td style="BACKGROUND-COLOR: #a8da8f;">Departure Time:</td>
<td align="center">
<input id="depTime" name="depTime" size="20"  TYPE="TEXT" style="float:left"></td>
</tr>
<tr>
<td style="BACKGROUND-COLOR: #a8da8f;">Arrival Time:</td>
<td align="center">
<input id="arrTime" name="arrTime" size="20"  TYPE="TEXT" style="float:left"></td>
</tr>
<tr>
<td style="BACKGROUND-COLOR: #a8da8f;">Source:</td>
<td bgcolor="#dfdfdf">
	<P align="left">
		<SELECT NAME="srcCity" ID="srcCity">
			<c:forEach var="city" items="${auxBean.cities}">
				<OPTION VALUE="${city.id}">${city.name}</OPTION>
			</c:forEach>
		</SELECT>
</td>
</tr>
<tr>
<td style="BACKGROUND-COLOR: #a8da8f;">Destination:</td>
<td bgcolor="#dfdfdf">
	<P align="left">
		<SELECT NAME="destCity" ID="destCity">
			<c:forEach var="city" items="${auxBean.cities}">
				<OPTION VALUE="${city.id}">${city.name}</OPTION>
			</c:forEach>
		</SELECT>
</td>
</tr>

<tr>
<td style="BACKGROUND-COLOR: #a8da8f;">Max Seats Count:</td>
<td align="center">
<input id="maxSeatsCount" name="maxSeatsCount" size="20"  TYPE="TEXT" style="float:left"></td>
</tr>

<tr align="center">
<td bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCC99">
  <INPUT TYPE="submit" NAME="submit" VALUE="Add"></td>
</tr>
</table>

</form>

<hr width="30%" align="left">
<%
if (flightID != null) {
	if (addFlag == true) {
%>
		The flight <font color="red"><i><b><%= flightID %></b></i></font> is added.
<%
	} else {
%>
		The flight <font color="red"><i><b><%= flightID %></b></i></font> is not added.
<%
	}
%>
	<hr width="30%" align="left">
<%
}
	addFlag = false;
%>

<a href="main.jsp">Main Page - Flight List</a>


<jsp:include page="footer.jsp"></jsp:include>
		
</body></html>